#ifndef SVL_TStackPtrFix_H
#define SVL_TStackPtrFix_H

#include "svl_TArrayFix.h"

namespace svl {

template <class T, int maxCount>
struct TStackPtrFix : public TArrayPtrFix<T,maxCount>
{
	void Push( T elem ) {
		if( count < maxCount ){
			Array[count] = elem;
			count++;
		}
		else
			Except("Push[else]");
	}
	
	T Pop() {
		if( count > 0 ){
		  count--;
			return Array[count];
	  }
		Except("Pop[else]");
		return NULL;
	}

	T GetPop() {
		if( count > 0 ){
			return Array[count-1];
	  }
		Except("GetPop[else]");
		return NULL;
	}
};




/*******
template <class T, int maxCount>
struct TStackPtrFix : public TDebug {
	TStackPtrFix(): count(0) {}
	//
	void Push( T elem ){
		if( count < maxCount ){
			Array[count] = elem;
			count++;
		}
		else
			Except("Push[else]");
	}
	
	T Pop() {
		if( count > 0 ){
		  count--;
			return Array[count];
	  }
		Except("Pop[else]");
		return NULL;
	}

	T GetPop() {
		if( count > 0 ){
			return Array[count-1];
	  }
		Except("GetPop[else]");
		return NULL;
	}

	void Clear() { count = 0; }
	int Count() { return count; }
	size_t MaxCount() { return sizeof(Array)/sizeof(T); }

private:
	T Array[maxCount];
	int count;
	svl_Except;
};
***********************/

///////////////////////////////////////////////////////////////////////////////
}

#endif